Micron Document




Python (programming language)
part 32/106 · 174.3 KB total
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Python uses arbitrary-precision arithmetic for all integer operations. The Decimal type/class in the decimal module provides decimal floating-point numbers to a pre-defined arbitrary precision with several rounding modes.cite-ref-autont-88-116-0[113] The Fraction class in the fractions module provides arbitrary precision for rational numbers.cite-ref-117[114]

Due to Python's extensive mathematics library and the third-party library NumPy, the language is frequently used for scientific scripting in tasks such as numerical data processing and manipulation.cite-ref-118[115]cite-ref-119[116]

Function syntax

Functions are created in Python by using the def keyword. A function is defined similarly to how it is called, by first providing the function name and then the required parameters. Here is an example of a function that prints its inputs:

def printer(input1, input2="already there"):
print(input1)
print(input2)
printer("hello")
# Example output:
# hello
# already there

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────